//
// Created by Administrator on 2023/6/26.
//

#ifndef WEAKCALLBACK_WIDGET_H
#define WEAKCALLBACK_WIDGET_H

#include <string>
#include <thread>
#include <chrono>

class Widget {
    std::string name_;
    int id_;
public:
    explicit Widget(int id)
    : id_(id)
    , name_(std::string("widget ").append(std::to_string(id))) {
        using namespace std::literals;
        //耗时创建
        std::this_thread::sleep_for(3s);
    }
    [[nodiscard]] const std::string& getName() const {
        return name_;
    }

    [[nodiscard]] int getId() const {
        return id_;
    }

};


#endif //WEAKCALLBACK_WIDGET_H
